import type { AddressItem, AddressParams } from '@/types/address'
import { http } from '@/utils/http'

// 新增地址
export const postMemberAddress = (data: AddressParams) => {
  return http({
    url: '/member/address',
    method: 'POST',
    data,
  })
}

// 获取地址列表数据
export const getMemberAddress = () => {
  return http<AddressItem[]>({
    url: '/member/address',
    method: 'GET',
  })
}

// 获取地址信息详情
export const getMemberAddressDetail = (id: string) => {
  return http<AddressItem>({
    url: `/member/address/${id}`,
    method: 'GET',
  })
}

// 修改收货地址
export const putMemberAddress = (id: string, data: AddressParams) => {
  return http({
    url: `/member/address/${id}`,
    method: 'PUT',
    data,
  })
}

// 删除地址信息
export const deleteMemberAddressDetail = (id: string) => {
  return http<AddressItem>({
    url: `/member/address/${id}`,
    method: 'DELETE',
  })
}